<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link href="../css/aui.css" rel="stylesheet" type="text/css"/>
    <link href="../css/aui-iconfont.css" rel="stylesheet"/>
    <link href="../css/index.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="../js/jstree/themes/default/style.min.css" />
    <style type="text/css">
        textarea{
            height: 300px;
        }
        body{
            background: #ffffff;
        }
    </style>
</head>
<body>
<div id="tab1_context"></div>
<script src="../js/template.js" type="text/javascript"></script>
<script src="../js/api.js" type="text/javascript"></script>
<script src="../js/jquery.min.js" type="text/javascript"></script>
<script src="../js/jstree/jstree.min.js" type="text/javascript"></script>

 <script type="text/javascript">

     //载入完成执行
     $api.onReady(function(){
         getAsFileInfo();
     });

     //获取android studio 当前打开的页面并获取view节点
     var fileInfo ;//AS文件信息
     function getAsFileInfo(){
         $api.getAsFileInfo(function(res,err){
             if(res){
                 fileInfo = res;
                 $api.html($api.byId('tab1_context'),'');
                 var layouts = fileInfo.layouts;
                 if(layouts&&layouts.length>0){
                     for(var i = 0 ;i<layouts.length;i++){
                         getView(layouts[i].path);
                     }
                 }
                 if(fileInfo.modelPath){
                     $api.html($api.byId('add_icon_tips'),'将在'+fileInfo.modelPath+'/res目录下自动裁剪各种规格的mipmap图片');
                 }else{
                     $api.html($api.byId('add_icon_tips'),'请在android studio里选择一个activity页面<button class="aui-btn" onclick="getAsFileInfo();">刷新</button>');
                 }
             }else{
                 $api.html($api.byId('tab1_context'),'<div class="layout aui-col-xs-12">' +
                     '<div class="aui-col-xs-10">'+err.message+'</div>' +
                     '<div class="aui-col-xs-2">' +
                     '<a class="aui-btn" style="float: right" onclick="getAsFileInfo();">刷新</a>' +
                     '</div></div>');
                 $api.html($api.byId('add_icon_tips'),'您未打开android studio<button class="aui-btn" onclick="getAsFileInfo();">刷新</button>');
             }
         });
     }
     function getView(path){
         $api.getView(path,function(res,err){
             if(res){
                 $api.append($api.byId('tab1_context'),JSON.stringify(res));
             }else{
                 alert(JSON.stringify(err));
             }
         });
     }
     var apiInfos ;
     var domains;
     var selectDomain;
     function getDomainInfo(){
         $api.getDomainInfo(function (res,err) {
             if(res){
                 domains = res;
             }else{

             }
         });
     }
 </script>
</body>
</html>